﻿package com.gengine.resource
{
    import com.gengine.resource.info.*;
    import flash.system.*;
    import flash.utils.*;

    public class ResourceManager extends Object
    {
        private static var _resourceNameMap:Dictionary = new Dictionary();
        private static var _instance:ResourceManager;

        public function ResourceManager()
        {
            return;
        }// end function

        public static function addResource(param1:ResourceInfo) : void
        {
            _resourceNameMap[param1.name] = param1;
            return;
        }// end function

        public static function removeResource(param1:ResourceInfo) : void
        {
            delete _resourceNameMap[param1.name];
            return;
        }// end function

        public static function getInfoByName(param1:String) : ResourceInfo
        {
            return _resourceNameMap[param1] as ResourceInfo;
        }// end function

        public static function hasInfoByName(param1:String) : Boolean
        {
            return param1 in _resourceNameMap;
        }// end function

        public static function disposeAll() : void
        {
            var _loc_1:ResourceInfo = null;
            for each (_loc_1 in _resourceNameMap)
            {
                
                _loc_1.dispose();
            }
            System.gc();
            return;
        }// end function

        public static function get resourceNameMap() : Dictionary
        {
            return _resourceNameMap;
        }// end function

        public static function getStr(param1:String) : String
        {
            var _loc_3:ResourceInfo = null;
            var _loc_2:String = "";
            for each (_loc_3 in _resourceNameMap)
            {
                
                if (!_loc_3.isDispose && _loc_3.isHasLoaded)
                {
                    _loc_2 = _loc_2 + (_loc_3.name + ":" + _loc_3.referenceCount + param1);
                }
            }
            return _loc_2;
        }// end function

    }
}
